import string
from random import choice


def generate_random(random_len, random_type):
    """
    随机生成字符串
    :param random_len: 生成的字符串长度
    :param random_type: 字符串类型（0：纯数字 or 1：数字+字符 or 2：数字+字符+特殊字符）
    :return: 生成的随机字符串
    """
    # 随机字符串种子
    random_seed = None
    if random_type == 0:
        random_seed = string.digits
    elif random_type == 1:
        random_seed = string.digits + string.ascii_letters
    elif random_type == 2:
        random_seed = string.digits + string.ascii_letters + string.punctuation

    random_str = []
    while len(random_str) < random_len:
        random_str.append(choice(random_seed))
    return ''.join(random_str)


if __name__ == '__main__':
    print(generate_random(6, 0))
